package com.learning.cloud.feign;

import com.learning.cloud.entity.User;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * description:
 *
 * @author minghuiZhang
 * @date created in  16:03 2018/5/5
 * modified by
 */
@Component
@Slf4j
public class HystrixClientFallbackFactory implements FallbackFactory<UserFeignClient> {
	@Override
	public UserFeignClient create(Throwable cause) {
		log.info("fallback; reason was: " + cause.getMessage());
		return username -> new User().id(-1L).username("fallback; reason was: " + cause.getMessage()).build();
	}
}
